﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebApp.Common
{
    public class ExceptionHelper
    {
        /// <summary>
        /// 获取实体验证失败错误i西宁西
        /// </summary>
        /// <param name="ex"></param>
        /// <returns></returns>
        public static string GetValidationErrorMessage(System.Data.Entity.Validation.DbEntityValidationException ex)
        {
            string errmsg = "";

            foreach (var valid in ex.EntityValidationErrors)
            {
                foreach (var error in valid.ValidationErrors)
                {
                    errmsg += error.ErrorMessage + "\n";
                }
            }

            return errmsg;
        }
    }
}
